// 模拟资源列表
const resources = ['resource1', 'resource2', 'resource3'];

// 模拟任务列表
const tasks = [
    { name: 'Task 1', resource: 'resource1' },
    { name: 'Task 2', resource: 'resource2' },
    { name: 'Task 3', resource: 'resource3' }
];

// 模拟流程列表
const flow = [
    { step: 1, taskIndex: 0 },
    { step: 2, taskIndex: 1 },
    { step: 3, taskIndex: 2 }
];

// 模拟任务进度
const taskProgress = {};

// 模拟执行任务的函数
function executeTask(task) {
    return new Promise((resolve, reject) => {
        // 模拟任务执行时间
        setTimeout(() => {
            console.log(`Executing ${task.name} using ${task.resource}`);
            resolve();
        }, 1000);
    });
}

// 执行流程
async function executeFlow() {
    for (const step of flow) {
        const task = tasks[step.taskIndex];
        taskProgress[task.name] = 'In Progress';
        await executeTask(task);
        taskProgress[task.name] = 'Completed';
        console.log(`Task ${task.name} completed`);
    }

    console.log('All tasks completed');
    console.log('Task Progress:', taskProgress);
}

// 执行流程
executeFlow().catch(err => console.error(err));
